package cn.hznc.controller.toolconnect;

import cn.hznc.aspect.BusinessType;
import cn.hznc.aspect.Log;
import cn.hznc.controller.service.toolConnect.ToolConnectService;
import cn.hznc.domain.request.toolconnect.AddOrEditToolConnectReq;
import cn.hznc.domain.request.toolconnect.QryToolConnectListReq;
import cn.hznc.domain.request.toolfork.CreateAssemblyToolReq;
import cn.hznc.domain.response.ResponseBody;
import cn.hznc.permission.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：Administrator
 * @Date：2023/12/18 15:48
 */
@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/assemblyTool")
public class ToolConnectController{

    @Autowired
    private ToolConnectService toolConnectService;

    /**
     * 查询关联关系
     *
     * @return Boolean
     */
    @RequestMapping(value = "/qryToolConnectList", method = RequestMethod.POST)
    @Permission(title = "查询关联关系" , permissions = {"toolConnect.read"})
    public ResponseBody qryToolConnectList(@RequestBody QryToolConnectListReq qryToolConnectListReq) {
        return ResponseBody.success(toolConnectService.qryToolConnectList(qryToolConnectListReq));
    }

    /**
     * 新增与修改关联关系
     *
     * @return Boolean
     */
    @RequestMapping(value = "/addOrEditToolConnect", method = RequestMethod.POST)
    @Log(title = "编辑或修改刀号与零件关联关系" , businessType = BusinessType.OTHER)
    @Permission(title = "编辑或修改刀号与零件关联关系" , permissions = {"toolConnect.add" , "toolConnect.update"})
    public ResponseBody
    addOrEditToolConnect(@RequestBody AddOrEditToolConnectReq addOrEditToolConnectReq) {
        return ResponseBody.success(toolConnectService.addOrEditToolConnect(addOrEditToolConnectReq));
    }

    /**
     * 删除刀号与零件关联关系
     *
     * @return Boolean
     */
    @RequestMapping(value = "/deleteBatch", method = RequestMethod.GET)
    @Log(title = "删除刀号与零件关联关系" , businessType = BusinessType.DELETE)
    @Permission(title = "删除刀号与零件关联关系" , permissions = {"toolConnect.delete"})
    public ResponseBody deleteBatch(@RequestParam("ids")List<Integer> ids) {
        return ResponseBody.success(toolConnectService.deleteBatch(ids));
    }
}
